package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TaskAssignmentTracking;
import com.ruoyi.system.service.ITaskAssignmentTrackingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * taskController
 * 
 * @author alex
 * @date 2025-07-17
 */
@RestController
@RequestMapping("/system/tracking")
public class TaskAssignmentTrackingController extends BaseController
{
    @Autowired
    private ITaskAssignmentTrackingService taskAssignmentTrackingService;

    /**
     * 查询task列表
     */
    @PreAuthorize("@ss.hasPermi('system:tracking:list')")
    @GetMapping("/list")
    public TableDataInfo list(TaskAssignmentTracking taskAssignmentTracking)
    {
        startPage();
        List<TaskAssignmentTracking> list = taskAssignmentTrackingService.selectTaskAssignmentTrackingList(taskAssignmentTracking);
        return getDataTable(list);
    }

    /**
     * 导出task列表
     */
    @PreAuthorize("@ss.hasPermi('system:tracking:export')")
    @Log(title = "task", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TaskAssignmentTracking taskAssignmentTracking)
    {
        List<TaskAssignmentTracking> list = taskAssignmentTrackingService.selectTaskAssignmentTrackingList(taskAssignmentTracking);
        ExcelUtil<TaskAssignmentTracking> util = new ExcelUtil<TaskAssignmentTracking>(TaskAssignmentTracking.class);
        util.exportExcel(response, list, "task数据");
    }

    /**
     * 获取task详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tracking:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(taskAssignmentTrackingService.selectTaskAssignmentTrackingById(id));
    }

    /**
     * 新增task
     */
    @PreAuthorize("@ss.hasPermi('system:tracking:add')")
    @Log(title = "task", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TaskAssignmentTracking taskAssignmentTracking)
    {
        return toAjax(taskAssignmentTrackingService.insertTaskAssignmentTracking(taskAssignmentTracking));
    }

    /**
     * 修改task
     */
    @PreAuthorize("@ss.hasPermi('system:tracking:edit')")
    @Log(title = "task", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TaskAssignmentTracking taskAssignmentTracking)
    {
        return toAjax(taskAssignmentTrackingService.updateTaskAssignmentTracking(taskAssignmentTracking));
    }

    /**
     * 删除task
     */
    @PreAuthorize("@ss.hasPermi('system:tracking:remove')")
    @Log(title = "task", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(taskAssignmentTrackingService.deleteTaskAssignmentTrackingByIds(ids));
    }
}
